﻿#define _CRT_SECURE_NO_WARNINGS
#include<stack>
#include<queue>
#include<iostream>
#include<vector>
#include<list>
using namespace std;

namespace my_stack
{
	//template<class T>
	//struct stack
	//{
	//public:
	//	//成员函数···

	//private:
	//	T* _a;
	//	size_t _top;
	//	size_t _capacity;
	//};

	/*template<class T>
	class stack
	{

	private:
		vector<T> _v;
	};*/

	/*template<class T, class Container>
	class stack
	{

	private:
		Container _con;
	};*/


	// Containerתstack
	template<class T, class Container = vector<T>>
	class stack
	{
	public:
		void push(const T& x)
		{
			_con.push_back(x);
		}

		void pop()
		{
			_con.pop_back();
		}

		const T& top() const
		{
			//return _con.func();
			return _con.back();
		}

		size_t size() const
		{
			return _con.size();
		}

		bool empty() const
		{
			return _con.empty();
		}

	private:
		Container _con;
	};
}

namespace my_list
{
	template<class T, class Container = list<T>>
	class queue
	{
	public:
		void push(const T& x)
		{
			_con.push_back(x);
		}

		void pop()
		{
			_con.pop_front();
		}

		const T& front() const
		{
			return _con.front();
		}

		const T& back() const
		{
			return _con.back();
		}

		size_t size() const
		{
			return _con.size();
		}

		bool empty() const
		{
			return _con.empty();
		}

	private:
		Container _con;
	};

}

void test13()
{
	srand(time(0));
	const int N = 1000000;

	deque<int> dq;
	vector<int> v;

	for (int i = 0; i < N; ++i)
	{
		auto e = rand() + i;
		v.push_back(e);
		dq.push_back(e);
	}

	int begin1 = clock();
	sort(v.begin(), v.end());
	int end1 = clock();

	int begin2 = clock();
	sort(dq.begin(), dq.end());
	int end2 = clock();

	printf(" vector:%d\n", end1 - begin1);
	printf(" deque:%d\n", end2 - begin2);
}

void test14()
{
	
	srand(time(0));
	const int N = 1000000;

	deque<int> dq1;
	deque<int> dq2;

	for (int i = 0; i < N; ++i)
	{
		auto e = rand() + i;
		dq1.push_back(e);
		dq2.push_back(e);
	}

	int begin1 = clock();
	sort(dq1.begin(), dq1.end());
	int end1 = clock();

	int begin2 = clock();
	// 拷贝到vector
	vector<int> v(dq2.begin(), dq2.end());
	sort(v.begin(), v.end());
	dq2.assign(v.begin(), v.end());
	int end2 = clock();

	printf(" deque sort:%d\n", end1 - begin1);
	printf(" deque copy vector sort, copy back deque:%d\n", end2 - begin2);

}

//int main()
//{
//	my_list::queue<int, vector<int>> q1;
//	q1.push(1);
//	q1.push(2);
//	q1.push(3);
//
//	q1.pop();
//
//	return 0;
//}

int main()
{
	test14();
	return 0;
}